def my_function():
    x = 10
    # local_vars = locals()
    x = 20
    local_vars = locals()
    print(local_vars)  # 输出 {'x': 10}
    print(x)  # 输出 20

my_function()